<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>添加老师信息</title>

    <link href="/layui/css/layui.css" rel="stylesheet">
    <script src="jquery.min.js"></script>
    <script src="/layui/layui.js"></script>
</head>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    .container{
        width: 50%;
        margin:0 auto;
        border: 2px solid #b2b2b2;
        margin-top: 20px;

    }
</style>
<body >
<div class="container">
    <form class="layui-form" style="margin-top: 20px">
        <div class="layui-form-item">
            <label class="layui-form-label">教师名称:</label>
            <div class="layui-input-inline">
                <input type="text" name="name" lay-verify="required" placeholder="请输入教师名称"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">教师性别:</label>
            <div class="layui-input-inline">
                <input type="radio" name="sex" value="男" title="男" >
                <input type="radio" name="sex" value="女" title="女">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">教师工资:</label>
            <div class="layui-input-inline">
                <input type="number" name="salary" lay-verify="required" placeholder="请输入教师工资"  class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">入职日期:</label>
            <div class="layui-input-wrap" style="display: inline-block;width: 190px">
                <div class="layui-input-prefix">
                    <i class="layui-icon layui-icon-date"></i>
                </div>
                <input type="text" name="hiredate"  readonly placeholder="请选择日期" class="layui-input demo-table-search-date">
            </div>
        </div>

        <div class="layui-form-item" style="display: none">
            <div class="layui-inline">

                <div class="layui-input-inline layui-input-wrap">
                    <input type="text" name="id" value="101"  autocomplete="off" lay-reqtext="请填写手机号" lay-affix="clear" class="layui-input demo-phone">
                </div>
            </div>
        </div>


        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">联系方式:</label>
                <div class="layui-input-inline layui-input-wrap">
                    <input type="tel" name="tel" lay-verify="required|phone" autocomplete="off" lay-reqtext="请填写手机号" lay-affix="clear" class="layui-input demo-phone">
                </div>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">家庭住址:</label>
            <div class="layui-input-block" style="width: 190px">
                <textarea placeholder="请输入内容" lay-verify="required" name="address" class="layui-textarea"></textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="add-submit">立即添加</button>
                <button type="reset" class="layui-btn layui-btn-primary">立即重置</button>
            </div>
        </div>

    </form>
</div>
<script>
    var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
    layui.use(function (){
        var form = layui.form;
        var laydate = layui.laydate;
        // 日期
        laydate.render({
            elem: '.demo-table-search-date'
        });
        //提交表单数据
        form.on('submit(add-submit)', function(data){
            var field = data.field; // 获取表单全部字段值
            $.post("insertTeacher",field,function (data){
                if(data==1){
                    //parent.layui.table.reload("ID-table-demo-search")
                    //重新加载父页面中的id为ID-table-demo-search的数据表格
                    parent.layui.table.reload("ID-table-demo-search");
                    layer.msg('恭喜您添加成功', {icon: 1,time: 1000}, function(){
                        parent.layer.close(index);
                    });
                }
            })
            return false; // 阻止默认 form 跳转
        })


    });

</script>
</body>
</html>